<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Mars激活</title>
<%@include file="../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css"/>
<link rel="stylesheet" type="text/css" href="${csspath }/datepicker.css"/>
<link rel="stylesheet" type="text/css" href="${csspath }/style_l.css"/>
<script type="text/javascript" src="${jspath }/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript" src="${layerPath}/layer.js"></script>
<script type="text/javascript" src="${jspath }/jquery.ui.min.js"></script>
<script type="text/javascript" src="${jspath }/ui.datepicker_zh-CN.js"></script>
<script type="text/javascript" src="${jspath }/jquery.blockUI.js"></script>
<script type="text/javascript" src="${jspath }/public.js"></script>
<script type="text/javascript" src="${jspath }/jquery.selectAll.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.alerts.js"></script>
<link rel="stylesheet" type="text/css" href="${csspath}/jquery.alerts.css" />
<link rel="stylesheet" type="text/css"
	href="${webcontext}/css/validationEngine.jquery.css" />
<script src="${jspath}/jquery/validate/jquery.validationEngine.js"
	type="text/javascript"></script>
<script src="${jspath}/jquery/validate/jquery.validationEngine-zh.js"
	type="text/javascript"></script>
	<script type="text/javascript"
	src="${webcontext}/javascript/jquery/jquery.ui.draggable.js"></script>
<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js"></script>
<script type="text/javascript">
$(function(){
	$("#saveAndSubmit").click(function(){
		if($("#packageNumber").val()==""){
			jAlert("卡号不能为空！");
			return;
		}
		if($("#packageActiveCode").val()==""){
			jAlert("验证码不能为空！");
			return;
		}
		
		jConfirm("确认激活？","确认提示",function(result){
    		if(result == true)
    		{	
    				$.ajax({
    					url:'${webcontext}/MARS/toSaveMemberActivationMars',
    					type:'post',
    					dataType : 'json',
    					data:$('form').serialize(),
    					beforeSend: function(){ 
  		  					layer.load(1);
  		  				},
    					success: function (data) {
    						layer.closeAll('loading');
    						if(data.errorMsg!=null){
           		                jAlert(data.errorMsg);
           		                }else{
       		                	  if(data.successMsg=="success"){
       	    		                	jAlert("激活成功！","提示信息",function(){
       	    		                		window.location.href="${webcontext}/crmdp/dealer/member/redirectMaintainMemberPage";
       	    		                	})
       	    		                }else{
       	    		                	jAlert(data.successMsg,"提示信息",function(){
       	    		                		window.location.href="${webcontext}/crmdp/dealer/member/redirectMaintainMemberPage";
       	    		                	})
       	    		               }
           		                }
    		            },
    		            error: function (msg) {
    		                alert(msg);
    		            }
    				})
    		}
    	});
		
	});
    
});

function idCardValid(value){
	var strP=/^(\d{15}|(\d{17}[\dXx]))$/;
	if(strP.test(value)){
		return true;
	}else{
		return false;
	}
}

function showDetail(){
	if($("#packageNumber").val()==""){
		jAlert("卡号不能为空！");
		return;
	}
	$.ajax({
		url:'${webcontext}/crmdp/dealer/activation/isPackageNumberExist',
		type:'post',
		data:$('form').serialize(),
		success: function (data) {
			  if(!data.success){
               	jAlert(data.error);
			  }else{
				//iframe层
					layer.open({
					    type: 2,
					    title: '详细信息',
					    shadeClose: false,
					    closeBtn: false,
					    shade: 0.1, 
					    offset : ['10%' , '25%'],
					    area: ['500px', '350px'],
					    content: "${webcontext}/crmdp/dealer/activation/toPurchaseDetailInfo?packageNumber="+$("#packageNumber").val(),//iframe的url
					    end: function(){ 
					    	//关闭弹出层后回调方法
					    }
					});  
			  }
        }
	});
}

</script>

</head>
<body>

	<!-- content -->
	<div id="content">
		<!-- wrap -->
		<div id="wrap">
        <!-- breadcrumb -->
		<!-- <div id="breadcrumba" style="color: #025D7B; height: 26px; line-height: 26px;">
			<span>驰加有道管理</span>
			<span>&gt;</span>
			<span>激活</span>
		</div> -->
			<!-- /breadcrumb -->
			<!-- info_div -->
 <form:form id="activate" action="${webcontext}/crmdp/dealer/activation/toSaveMemberActivation" method="post" modelAttribute="dto" enctype="multipart/form-data">
								<form:input type="hidden" path="memberId" name="id" value="${dto.memberId}"/>
						  		<form:input type="hidden" path="packageDefId" name="packageDefId"/>
						  		<form:input type="hidden" path="onhandQuantity"/>
						  		<form:input type="hidden" path="price"/>
 								<input type="hidden" id="dealerId" name="dealerId" value="${dto.dealerId}"/>
 								<input type="hidden" id="soNumberActive" name="soNumberActive" value="${dto.soNumber}"/>
 								<input type="hidden" id="operationType" name="operationType"/>
		  <div class="input_div">
                <div>
				 <style>
                .input_tab { table-layout:fixed; }
                </style>
                <div class="spliter h_10"></div>           
             	<div class="spliter h_5"></div>
				<table class="input_tab">
						 <tr>
		                       <td width="20%" style="text-align: right;padding-right: 40px;">手机：</td>
		                       <td ><form:input type="hidden" path="mobilePhone" cssClass="text" readonly="true"/>${dto.mobilePhone}</td>
	                     </tr>
	                      <tr>
		                       <td width="20%" style="text-align: right;padding-right: 40px;">姓名：</td>
	                           <td align="left"><form:input type="hidden" path="memberName" cssClass="text string" readonly="true"/>${dto.memberName}</td>
	                     </tr>
	                       <tr>
	                     	   <td width="20%" style="text-align: right;padding-right: 40px;">车牌：</td>
	                      	   <td align="left"><form:input type="hidden" id="carPlate" path="carPlate" cssClass="text" readonly="true"/>${dto.carPlate}</td>
	                     </tr>
	                     
					</table>
					<div class="spliter h_10"></div>           
             		<div class="spliter h_5"></div>
					<table class="input_tab">
					 	<tr>
		                       <td width="30%" style="text-align: right;padding-right: 150px;">卡号：</td>
		                       <td align="left">验证码：</td>
	                     </tr>
	                     <tr>
	                     	 <td align="right"  width="30%">
		                      			<form:input path="packageNumber" id="packageNumber" cssClass="form-control-inline input-sm validate[required] text string " sytle="display:inline;"/>&nbsp;&nbsp;&nbsp;
			                      		<button type="button" class="btn btn-success btn-xs btnLength" style="width:40px;"  onClick="showDetail()">详情</button>&nbsp;&nbsp;&nbsp;&nbsp;
		                      </td>
		                      <td align="left"><form:input path="packageActiveCode" id="packageActiveCode" cssClass="form-control-inline input-sm validate[required] text"/>${dto.errorMsg}</td>
	                     </tr>
					</table>
					<div class="spliter h_10"></div>           
             		<div class="spliter h_5"></div>
		    </div>
		  </div>
			<!-- /info_div -->
            
            <div class="spliter h_10"></div>           
             <div class="spliter h_5"></div>
            
            <div class="btn_div" style="width:600px">
                <button type="button" class="btn" style="width: 100px;" id="saveAndSubmit" value="激活">
                	<i class="glyphicon glyphicon-ok-sign" style="color:#FFFFFF"></i>&nbsp;激活
                </button>
                <button type="button" class="btn" style="width: 100px;" value="取消" id="cancel">
                	<i class="glyphicon glyphicon-share-alt" style="color:#FFFFFF"></i>&nbsp;取消
			    </button>
            </div>
             
      </form:form>  
      </div>
		<!-- /wrap -->
	</div>
	<!-- /content -->

  </body>

</html>